package com.example.forum.utils;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: DELL
 * Date: 2023-09-16
 * Time: 21:07
 */
public class StringUtil {
    public static boolean isEmpty(String str) {
        return str == null || str.length() == 0;
    }

    /**
     * 判断字符串中是否有空格
     * 若传入 null,则也返回 false
     *
     * @param str 待判断的字符串
     * @return
     */
    public static boolean hasSpace(String str) {
        if (!isEmpty(str)) {
            for (int i = 0; i < str.length(); i++) {
                if (str.charAt(i) == ' ') {
                    return true;
                }
            }
        }
        return false;
    }
}
